#include<iostream>


class Solution1688 {
public:
    int numberOfMatches(int n) {
        if (n == 0)return 0;
        int count = 0;
        while (n != 0 && n != 1) {
            count += n / 2;
            if (n % 2 == 0) n = n / 2;
            else n = n / 2 + 1;
        }
        return count;
    }
};